class code1 {
    
    public int[] sortArray(int[] nums) {
        return quickSort(nums,0,nums.length-1);
    }

    private int[] quickSort(int[] nums,int left,int right) {

        if(left < right) {
            int pid = partition(nums,left,right);
            quickSort(nums,left,pid-1);
            quickSort(nums,pid+1,right);
        }
        return nums;
    }
    private int partition(int[] nums,int left,int right) {
        int privot = left;
        int cur = privot + 1;
        for(int i=cur;i<=right;i++) {
            if(nums[i] < nums[privot]) {
                swap(nums,i,cur);
                cur++;
            }
        }
        swap(nums,cur-1,privot);

        return cur-1;
    }

    private void swap(int[] nums,int i,int j) {
        int tmp = nums[i];
        nums[i] = nums[j];
        nums[j] = tmp;
    }
}